package com.javasea.spring.event;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 事件的监听者，实现ApplicationListener接口
 * @Author longxiaonan@163.com
 * @Date 15:21 2022/3/23 0023
 **/
@Slf4j
@Component
public class ReconnectApplicationListener implements ApplicationListener<ReconnectApplicationEvent> {

    @SneakyThrows
    @Override
    public void onApplicationEvent(ReconnectApplicationEvent event) {
        log.info("收到重连事件，开始重连：[{}]", event.getMessage());
        Thread.sleep(5000);
        log.info("收到重连事件，重连结束", event.getMessage());
    }

}
